package com.kotlin.customview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * author : zhouyouqiang
 * e-mail : 1638473898@qq.com
 * date   : 2022/3/22 9:30
 * desc   : 画线
 * version: 1.0
 */
public class CustomLine extends View {

    public CustomLine(Context context) {
        super(context);
    }

    public CustomLine(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomLine(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public CustomLine(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }
    //创建画笔
    Paint paint=new Paint();
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //设置显示样式 实心 还是 空心
        paint.setStyle(Paint.Style.FILL);
        paint.setStrokeWidth(30);
        //设置绘制颜色
        paint.setColor(Color.parseColor("#000000"));
        //设置抗锯齿开关
        paint.setAntiAlias(true);
        //绘制一个圆
        canvas.drawLine(100,100,500,600,paint);
    }
}
